package com.ruoyi.yqhs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yqhs.domain.YqhsZxsj;
import com.ruoyi.yqhs.service.IYqhsZxsjService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 在线数据Controller
 * 
 * @author ruoyi
 * @date 2025-08-31
 */
@RestController
@RequestMapping("/yqhs/zxsj")
public class YqhsZxsjController extends BaseController
{
    @Autowired
    private IYqhsZxsjService yqhsZxsjService;

    /**
     * 查询在线数据列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:zxsj:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqhsZxsj yqhsZxsj)
    {
        startPage();
        List<YqhsZxsj> list = yqhsZxsjService.selectYqhsZxsjList(yqhsZxsj);
        return getDataTable(list);
    }

    /**
     * 导出在线数据列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:zxsj:export')")
    @Log(title = "在线数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqhsZxsj yqhsZxsj)
    {
        List<YqhsZxsj> list = yqhsZxsjService.selectYqhsZxsjList(yqhsZxsj);
        ExcelUtil<YqhsZxsj> util = new ExcelUtil<YqhsZxsj>(YqhsZxsj.class);
        util.exportExcel(response, list, "在线数据数据");
    }

    /**
     * 获取在线数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('yqhs:zxsj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yqhsZxsjService.selectYqhsZxsjById(id));
    }

    /**
     * 新增在线数据
     */
    @PreAuthorize("@ss.hasPermi('yqhs:zxsj:add')")
    @Log(title = "在线数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqhsZxsj yqhsZxsj)
    {
        return toAjax(yqhsZxsjService.insertYqhsZxsj(yqhsZxsj));
    }

    /**
     * 修改在线数据
     */
    @PreAuthorize("@ss.hasPermi('yqhs:zxsj:edit')")
    @Log(title = "在线数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqhsZxsj yqhsZxsj)
    {
        return toAjax(yqhsZxsjService.updateYqhsZxsj(yqhsZxsj));
    }

    /**
     * 删除在线数据
     */
    @PreAuthorize("@ss.hasPermi('yqhs:zxsj:remove')")
    @Log(title = "在线数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yqhsZxsjService.deleteYqhsZxsjByIds(ids));
    }
    /**
     * 获取最新进罐压
     * @param jyzId
     * @return
     */
    @GetMapping(value = "/getLastGuanYa/{jyzId}")
    public AjaxResult getLastGuanYa(@PathVariable("jyzId") Long jyzId)
    {
        return success(yqhsZxsjService.selectYqhsZxsjGuanYa(jyzId));
    }


}
